package org.example.aicloud.controller;

import jakarta.annotation.Resource;
import org.example.aicloud.entity.Comment;
import org.example.aicloud.service.ICommentService;
import org.example.aicloud.util.ResultAjax;
import org.example.aicloud.util.SecurityUtil;
import org.example.aicloud.util.idempotent.Idempotent;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    private ICommentService commentService;
    @RequestMapping("/add")
    @Idempotent
   public ResultAjax addComment(Comment comment){
        comment.setUid(SecurityUtil.getCurrentUser().getUid());
        boolean result = commentService.save(comment);
        if (result) {
            return ResultAjax.success(result);
        }

        return ResultAjax.error("评论失败");
   }
}
